package com.mxpio.erp.common.quality.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@Entity
@Table(name = "v_mb_erp_quality_unqualified_disposal")
@Schema(description="不良品处理展示模块")
@NoArgsConstructor
@AllArgsConstructor
public class VEUnqualifiedDisposal implements DictAble, Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Generator
    @Column(name = "ID_", updatable = false)
    @Schema(description = "ID")
    private String id;

    @Column(name = "DRAWING_NO_")
    @Schema(description = "图号")
    private String drawingNo;

    @Column(name = "ITEM_CODE_")
    @Schema(description = "物料代码")
    private String itemCode;

    @Column(name = "ITEM_NAME_")
    @Schema(description = "物料名称")
    private String itemName ;

    @Column(name = "SUBMIT_TIME_")
    @Schema(description = "提交时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date submitTime;

    @Column(name = "ORIGIN_BIZ_TYPE_")
    @Schema(description = "来源单类型")
    @Dict(dicCode="ERP_QUAL_ORIGIN_BIZ_TYPE")//同质检单字段，工作流发起时使用
    private String originBizType;

    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审核状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
    private String bpmnStatus;

    @Column(name = "UNQUALIFIED_QUANTITY_")
    @Schema(description = "不合格数量")
    private BigDecimal unqualifiedQuantity;

    @Column(name = "APPLY_DECISION_")
    @Schema(description = "申请使用决策")
    @Dict(dicCode = "ERP_QUAL_SUBLOT_USAGE_DECISION")
    private String applyDecision;

    @Transient
    private Map<String, String> textMap;

    public String putText(String key, String value) {
        if (textMap == null) {
            textMap = new HashMap<>();
        }
        return textMap.put(key, value);
    }
}
